#ifndef SIMULATOR2D_H
#define SIMULATOR2D_H
#include <glut.h>
#include "math/SCVector.h"

struct Grid{
	enum MTYPE{
		MTYPE_FLUID,
		MTYPE_AIR,
		MTYPE_SOLID,
	};
	int mType;

	int vDIndex;
	int vRIndex;
	int vUIndex;
	int vLIndex;

	float pressure;
	float interPressure;	//used by jacobi
	float divergency;
};

class Simulator2D{
public:
	Simulator2D(){}
	~Simulator2D(){}

	void Init(int xGridNum,int yGridNum);
	void Release();
	

	void Advection(float timeSinceLastFrame);
	void advectVelocity(Vector2 &v,const Vector2 &curPos);

	void BodyForce(float timeSinceLastFrame);

	void Projection(float timeSinceLastFrame);

	void jacobiIteraction();
	float getGridPressure(int iX,int iY);
	int	  countSolid(int iX,int iY);



	void AddVelocity(const Vector2 &startPos,const Vector2 &dMove);
	


	//Below for test
	void DrawGrid();
	void DrawVelocitySamplePoints();
	void __drawPoint(int index);


	void DrawSpeedField();

	int m_xGridNum;
	int m_yGridNum;

	
	Grid	* m_grid;


	Vector2 *m_v;
	Vector2 *m_interV;
	int		 m_iVSize;




	float m_deltaTime;			//time step
	float m_density;				
	Vector2 m_externForce;
	
};











#endif